package com.kajespero.dao.summary.impl;

import java.util.Collection;

import com.kajespero.dao.commons.impl.AbstractReadWriteDAO;
import com.kajespero.dao.summary.SummaryDAO;
import com.kajespero.jdo.Criteria;
import com.kajespero.model.PageBean;
import com.kajespero.model.SummaryBean;
import com.kajespero.model.annotation.process.MappedValueProcess;
import com.kajespero.vo.SummaryVO;

public class SummaryDAOImpl extends AbstractReadWriteDAO<SummaryBean, Long> implements SummaryDAO{

	@Override
	public SummaryBean createNewBean() throws InstantiationException,IllegalAccessException {
		SummaryBean summary = new SummaryBean();
		summary.setId(nextId());
		summary.setKey(createKey(summary.getId()));
		return summary;
	}

	@Override
	public Collection<PageBean> findPageBySummary(SummaryVO summary) {
		Criteria<PageBean> criteria = new Criteria<PageBean>(PageBean.class);
		criteria.addProperty("summaryId", summary.getKey());		
		return MappedValueProcess.processPostLoad(criteria.executeCriteria());
	}

}
